<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品管理 - 后台管理</title>
    <style>
        .container {
            padding: 20px;
        }
        .search-bar {
            margin-bottom: 20px;
            display: flex;
            gap: 10px;
        }
        .search-input {
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        .search-btn {
            padding: 8px 15px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .add-btn {
            padding: 8px 15px;
            background-color: #2ecc71;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-bottom: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
            font-weight: bold;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        .action-btn {
            padding: 5px 10px;
            margin: 0 5px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        .edit-btn {
            background-color: #3498db;
            color: white;
        }
        .delete-btn {
            background-color: #e74c3c;
            color: white;
        }
    </style>
</head>
<body>
    <%@ include file="../header.jsp" %>
    
    <div class="container">
        <h1>商品管理</h1>
        
        <button class="add-btn" onclick="location.href='product_add.jsp'">添加商品</button>
        
        <div class="search-bar">
            <input type="text" class="search-input" placeholder="输入商品名称">
            <button class="search-btn">搜索</button>
        </div>
        
        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>商品名称</th>
                    <th>价格</th>
                    <th>类型ID</th>
                    <th>状态</th>
                    <th>是否置顶</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>示例商品1</td>
                    <td>¥99.00</td>
                    <td>1</td>
                    <td>正常</td>
                    <td>是</td>
                    <td>
                        <button class="action-btn edit-btn" onclick="editProduct(1)">编辑</button>
                        <button class="action-btn delete-btn" onclick="deleteProduct(1)">删除</button>
                    </td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>示例商品2</td>
                    <td>¥199.00</td>
                    <td>2</td>
                    <td>正常</td>
                    <td>否</td>
                    <td>
                        <button class="action-btn edit-btn" onclick="editProduct(2)">编辑</button>
                        <button class="action-btn delete-btn" onclick="deleteProduct(2)">删除</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    
    <script>
        function editProduct(id) {
            window.location.href = 'product_edit.jsp?id=' + id;
        }
        
        function deleteProduct(id) {
            if (confirm('确定要删除这个商品吗？')) {
                // 实际项目中这里会发送删除请求到后端
                alert('商品已删除');
            }
        }
    </script>
</body>
</html>